package recursion;

/**
 * @author czt
 * @version 1.0
 * @since 2024/12/12
 *
 * 求阶乘
 */
public class Factorial {

    public static void main(String[] args) {
        int num = factorial(5);

        System.out.println("num = " + num);
    }

    public static int factorial(int n) {
        // 当n为0或1时，返回1
        if(n == 0 || n == 1) return 1;

        return n * factorial(n - 1);
    }
}
